import 'package:flutter/material.dart';

class Widget_GridView_Custom_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Widget_GridView_Custom_State_Page();
  }
}

class Widget_GridView_Custom_State_Page
    extends State<Widget_GridView_Custom_Page> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("GridView custom方式"),
        ),
        body: GridView.custom(
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
            mainAxisSpacing: 10,
            crossAxisSpacing: 10,
            childAspectRatio: 1,
          ),
          childrenDelegate: SliverChildBuilderDelegate(
                  (context, position) {
                return Container(
                  color: Color(0xfff1f1f1),
                  child: Text("aaaaaaaaaaaaaaaa"),
                );
              },
              childCount: 20,
          ),
        ),
      ),
    );
  }
}